function LazyMan(name) {
  this.task = [];
  let fn = () => {
    console.log('this is ' + name);
    this.next();
  };
  this.task.push(fn);
  setTimeout(() => {
    this.next();
  }, 0);
  return this;
}
LazyMan.prototype.eat = function (eatName) {
  let that = this;
  this.task.push(() => {
    console.log('eat ' + eatName);
    that.next();
  });
  return this;
};
LazyMan.prototype.sleep = function (time) {
  let that = this;
  this.task.push(() => {
    setTimeout(() => {
      console.log('sleep ' + time);
      that.next();
    }, time * 1000);
  });
  return this;
};
LazyMan.prototype.next = function (dinner) {
  let fn = this.task.shift();
  fn && fn();
};
let xx = new LazyMan('mdzz')
  .sleep(2)
  .eat('wx');
